package com.example.password.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.password.mapper.UserMapper;
import com.example.password.pojo.User;
import com.example.password.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;

    @Override
    public int login(User user) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("username", user.getUsername());
        User result = (User) userMapper.selectOne(wrapper);
        if (result != null && result.getPassword().equals(user.getPassword())) {
            return 1;
        } else {
            return 0;
        }
    }

    @Override
    public int logout() {
        return 0;
    }
}
